import { defineComponent, h, onMounted, onUnmounted, ref, watch } from 'vue'

export const CanvasTable = defineComponent({
  name: 'CanvasTable',
  // 组件初始化
  setup() {
    const canvas = ref(null)
    const container = ref(null)
    const data = ref()
    const handleClick = () => {}

    const drawTable = () => {
      console.log('drawTable')
    }

    onMounted(() => {
      drawTable()
    })

    onUnmounted(() => {})

    watch(data, () => {
      drawTable()
    })

    return {
      handleClick,
      canvas,
      container
    }
  },
  // 渲染
  render() {
    return h('div', {}, this.$slots.default?.())
  }
})
